<?php
session_start();
include_once "checkLogin.php";
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link href="css/menu.css" rel="stylesheet" type="text/css"/>
    <script src="js/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="js/nav.js" type="text/javascript"></script>
    <link rel="stylesheet" href="layui/css/layui.css">
    <script src="js/TweenMax.min.js"></script>
    <link href="css/word.css" rel="stylesheet" type="text/css"/>
    <title>借阅到期提醒</title>
    <style>
        #content thead tr{
            background-color:#E2F5F7;
        }
        #content thead th{
            color: black;
            font-weight: bold;
            border-right: 2px solid  white;
            text-align: center;
        }
        table td{
            color: black;
        }
        tbody td a{
            font-size: 1.1em;
            color: skyblue;
            cursor: pointer;
        }
    </style>
</head>
<body>
<canvas id="Mycanvas" style="position: absolute;left: 0%;width: 100%;height: 99%"></canvas>
<div id="main">
    <header>
        <div id="header1">
            <div id="a"></div>
            <img src="img/logo1.png">
            <h2 class="letter-wrap"  data-stagger="-0.015">清华大学图书馆管理系统</h2>
            <span>当前登录用户：
                <?php echo $_SESSION['admin']?></span>
        </div>
    </header>
    <div class="navmain">
        <div id="time"><span></span></div>
        <ul id="nav_all">
            <li><a href="index.php">首页</a></li>
            <?php
            include_once "conn.php";
            $main = new main();
            $info = $main->checkAdmin($_SESSION['admin']);
            if ($info['system']){
                ?>
                <li><a href="#">系统设置</a>
                    <ul style="display: none;">
                        <li><a href="library.php">图书馆信息</a></li>
                        <li><a href="admin.php">管理员设置</a></li>
                        <li><a href="#">参数设置</a></li>
                        <li><a href="shujia.php">书架设置</a></li>
                    </ul>
                </li>
                <?php
            }
            if ($info['readerset']){
                ?>
                <li><a href="#">读者管理</a>
                    <ul style="display: none;">
                        <li><a href="readertype.php">读者类型管理</a></li>
                        <li><a href="user.php">读者档案管理</a></li>
                    </ul>
                </li>
                <?php
            }
            if ($info['bookset']){
                ?>
                <li><a href="tushudangan.php">图书档案管理</a></li>
                <?php
            }
            if ($info['book']){
                ?>
                <li><a>图书借还</a>
                    <ul style="display: none;">
                        <li><a href="bookjieyue.php">图书借阅</a></li>
                        <li><a href="bookxujie.php">图书续借</a></li>
                        <li><a href="bookback.php">图书归还</a></li>
                    </ul>
                </li>
                <?php
            }
            if ($info['syschaxun']){
                ?>
                <li> <a>系统查询</a>
                    <ul style="display: none;">
                        <li><a href="tushudanganchaxun.php">图书档案查询</a></li>
                        <li><a href="jieyuechaxun.php">图书借阅查询</a></li>
                        <li><a href="jieyue.php">借阅到期提醒</a></li>
                    </ul>
                </li>
                <?php
            }
            ?>
            <li>
                <a href="pw.php">更改口令</a>
            </li>
            <li><a href="zhuxiao.php">注销</a> </li>
        </ul>
    </div>
    <div id="b"></div>
    <div id="c">
        <div id="now">当前位置：系统查询 > 借阅到期提醒 >>></div>
        <div id="content">
            <table class="layui-table" lay-even  lay-skin="nob">
            <colgroup>
                <col width="150">
                <col>
            </colgroup>
            <thead>
            <tr>
                <th>序号</th>
                <th>图书条形码</th>
                <th>图书名称</th>
                <th>读者条形码</th>
                <th>读者名称</th>
                <th>借阅时间</th>
                <th>应还时间</th>
            </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
            <div id="demo7" style="position: absolute;margin-left: 30px"></div>
        </div>
    </div>
    <footer>
        <hr id="one">
        <hr id="two">
        CopyRight © 2019 www.cdp.cn.com 清华大学图书馆
    </footer>
</div>
</body>
<script src="layui/layui.js"></script>
<script src="js/bg.js"></script>
<script src="js/logo.js"></script>
<script>
    layui.use(['layer', 'form', 'laydate','laypage'], function () {
        kaitime = "";
        huantime = "";
        var layer = layui.layer,
            form = layui.form,
            laydate = layui.laydate
            ,laypage = layui.laypage;
        $.ajax({
            type: "POST",
            url: "jie.php",
            data: {
                tiaojian:0
            },
            dataType: 'JSON',
            cache: false, //不缓存此页面
            success: function (data) {
                zs = data.length;
                laypage.render({
                    elem: 'demo7'
                    ,limit:13
                    ,count: zs
                    ,jump: function(obj){
                        xuhao = (obj.curr - 1) * obj.limit + 1;
                        console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                        console.log(obj.limit); //得到每页显示的条数
                        $.ajax({
                            type: "POST",
                            url: "jie.php",
                            data: {
                                one : obj.curr,
                                two : obj.limit,
                                tiaojian:1
                            },
                            dataType: 'JSON',
                            cache: false, //不缓存此页面
                            beforeSend: function () {
                                $("#load").css('display', 'block');
                            },
                            success: function (data) {
                                cg(data);
                            }, error(a, b, c) {
                                $("#load").css('display', 'none');
                                console.log(a, b, c);
                            }
                        });
                    }
                });
            }
        });
        function formatDateTime(inputTime) {
            var date = new Date(inputTime);
            var y = date.getFullYear();
            var m = date.getMonth() + 1;
            m = m < 10 ? ('0' + m) : m;
            var d = date.getDate();
            d = d < 10 ? ('0' + d) : d;
            return y + '-' + m + '-' + d;
        }
        function cg(data){
            console.log(a);
            $("#load").css('display', 'none');
            console.log(data);
            if (data.length === 0) {
                $("#null").css('display', 'block');
                $("#demo7").css('display', 'none');
            } else {
                $("#null").css('display', 'none');
                $("#demo7").css('display', 'block');
            }
            document.querySelector("tbody").innerHTML = '';
            for (let i = 0; i < data.length; i++) {
                let s =
                    `<tr>
                                    <td>${xuhao} </td>
                                    <td>${data[i]['bookcode']} </td>
                                    <td>
                                        <a href="xiugaibook.php?id=${data[i]['bookid']}">${data[i]['bookname']}</a>
                                    </td>
                                    <td>${data[i]['barcode']} </td>
                                    <td>${data[i]['user']}</td>
                                    <td> ${formatDateTime(data[i]['jietime']*1000)}</td>
                                    <td> ${formatDateTime(data[i]['backtime']*1000)}</td>
                            </tr>`;
                var key = s.split(a);
                s = key.join(`<span style="color: red">${a}</span>`);
                document.querySelector("tbody").innerHTML += s;
                xuhao++;
            }
        }
    });
</script>
</html>


